/**
 * Created by jiaxing on 2017/11/13.
 */
$(function () {
    
    //导航下拉
    var lis = $(".nav1_ul").children();
    for(var i=0;i<lis.length;i++){
        lis[i].onmouseover = function () {

            $(this).children(".slider").css("display","block");
            $(this).children(".slider").css("opacity","1");
            //$(this).children(".slider").slideDown();
        }
        lis[i].onmouseout = function () {

            $(this).children(".slider").css("display","none");
            $(this).children(".slider").css("opacity","0");
            //$(this).children(".slider").slideUp();
        }
    }
    var lis2 = $(".nav2_ul").children();
    for(var i=0;i<lis2.length;i++){
        lis2[i].onmouseover = function () {
            $(this).children(".slider").css("opacity","1");
            $(this).children(".slider").css("display","block");
        }
        lis2[i].onmouseout = function () {
            $(this).children(".slider").css("opacity","0");
            $(this).children(".slider").css("display","none");
        }
    }
    var topHeight = 46;
   
    $(window).scroll(function () {
        var scrolltop = $(document).scrollTop();
        if(scrolltop>=topHeight){
            $(".nav1").css({
                "position":"fixed",
                top:0
            })
            $(".logo").css("transform","scale(.5)");
            $(".logo").css("top","-46px");
        }else{
            $(".nav1").css({
                "position":"relative",
            })
            $(".logo").css("transform","scale(1)");
            $(".logo").css("top","0px");
        }
    })
    
    var obj = {
            url:"/shixun/new?plate=主页",
            dataType:"json",
            type:"get",
            success:function(data){
                var Data = data;
                var kdxw = [];
                var zhxw = [];
                var mtgz = [];
                var tzgg = [];
                var xsjl = [];
                   

                   //科大要闻新闻
                    for(var i=0;i<Data.length;i++){
                
                        if(Data[i].modula=="科大要闻"){
                        kdxw.push(Data[i]);
                         }
                
                    }
            
                    var part1 = $(".part1 a").children();
                    part1.eq(0).src=kdxw.pic ;
                    part1.eq(1).html(kdxw[0].title);
                    part1.eq(2).html(kdxw[0].content.substr(0,50)+"……");
                    part1.eq(3).html(kdxw[0].time);

                    var part2 = $(".part2 a").children();
                    part2.eq(0).src=kdxw.pic ;
                    part2.eq(1).html(kdxw[1].title);
                    part2.eq(2).html(kdxw[1].content.substr(0,50)+"……");
                    part2.eq(3).html(kdxw[1].time);

                    var part3 = $(".part3 a").children();
                    part3.eq(0).src=kdxw.pic ;
                    part3.eq(1).html(kdxw[2].title);
                    part3.eq(2).html(kdxw[2].content.substr(0,50)+"……");
                    part3.eq(3).html(kdxw[2].time);

                    
                    //综合新闻
                    for(var i=0;i<Data.length;i++){
                
                        if(Data[i].modula=="综合新闻"){
                        zhxw.push(Data[i]);
                         }               
                    }
                    var zhxw_titles = document.getElementsByClassName("zhxw_title");
                    for(var i=0;i<zhxw_titles.length;i++){
                        zhxw_titles[i].innerHTML=zhxw[i].title.substr(0,11)+"……";
                    }
                    var zhxw_date = document.getElementsByClassName("time1");
                    for(var i=0;i<zhxw_date.length;i++){
                        zhxw_date[i].innerHTML=zhxw[i].time;
                    }


                    //媒体关注
                    for(var i=0;i<Data.length;i++){
                
                        if(Data[i].modula=="媒体关注"){
                        mtgz.push(Data[i]);
                         }               
                    }
                    var mtgz_titles = document.getElementsByClassName("mtgz_title");
                    for(var i=0;i<mtgz_titles.length;i++){
                        mtgz_titles[i].innerHTML=mtgz[i].title;
                    }
                    var mtgz_date = document.getElementsByClassName("time2");
                    for(var i=0;i<mtgz_date.length;i++){
                        mtgz_date[i].innerHTML=mtgz[i].time;
                    }


                    //通知公告
                    for(var i=0;i<Data.length;i++){
                
                        if(Data[i].modula=="通知公告"){
                        tzgg.push(Data[i]);
                         }               
                    }
                    var tzgg_titles = document.getElementsByClassName("tzgg_title");
                    for(var i=0;i<tzgg_titles.length;i++){
                        tzgg_titles[i].innerHTML=tzgg[i].title;
                    }
                    var tzgg_date = document.getElementsByClassName("time3");
                    for(var i=0;i<tzgg_date.length;i++){
                        tzgg_date[i].innerHTML=tzgg[i].time;
                    }


                    //学术交流
                    for(var i=0;i<Data.length;i++){
                
                        if(Data[i].modula=="学术交流"){
                        xsjl.push(Data[i]);
                         }               
                    }
                    var xsjl_titles = document.getElementsByClassName("xsjl_title");
                    for(var i=0;i<xsjl_titles.length;i++){
                        xsjl_titles[i].innerHTML=xsjl[i].title;
                    }
                    var xsjl_date = document.getElementsByClassName("time4");
                    for(var i=0;i<xsjl_date.length;i++){
                        xsjl_date[i].innerHTML=xsjl[i].time;
                    }


},
            error:function(e){
                            console.log(e);
                        }
            }
    $.ajax(obj);

})
